"""
@File    : shape.py
@Author  : WorldWind(1772830365@qq.com)
@Time    : 2025/7/14
@Address : ChangSha - BoWeiFeng
@Date    : 2025/7/14 下午4:25
"""


class Shape:
    length = 0
    width = 0

    def __init__(self, length, width):
        self.length = length
        self.width = width
        print(f'This is __init__ method. {self.get_class_name()} class startup')

    # 周长
    def perimeter(self):
        pass

    # 面积
    def area(self):
        pass

    @classmethod
    def get_class_name(cls):
        return cls.__name__

    def __del__(self):
        print('This is __del__ method. The Shape class has been recycled')


class Person:
    def __init__(self):
        print(f'This is __init__ method. {self.get_class_name()} class startup')

    @classmethod
    def get_class_name(cls):
        return cls.__name__

    def __del__(self):
        print(f'This is __del__ method. The {self.get_class_name()} class has been recycled')


class Rectangle(Shape):
    def perimeter(self):
        return round((self.width + self.length) * 2, 2)

    def area(self):
        return round(self.width * self.length, 2)


class Circle(Shape):
    def __init__(self, r):
        self.r = r

    def area(self):
        return round(3.14 * self.r ** 2, 2)

    def perimeter(self):
        return round(2 * 3.14 * self.r, 2)


if __name__ == '__main__':
    c = Circle(5)
    print(c.area())
    print(c.perimeter())
    r = Rectangle(3.2, 2.2)
    print(r.area())
    print(r.perimeter())
